package com.kuangjia.student_ems.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Entity
@Table(name = "attendance_locations")
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("attendance_locations")
public class AttendanceLocation {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(value = "id", type = com.baomidou.mybatisplus.annotation.IdType.AUTO)
    private Long id;

    @TableField("attendance_id")
    private Long attendanceId;

    @TableField("user_id")
    private Long userId;

    private LocalDate date;

    @Enumerated(EnumType.STRING)
    private LocationType locationType;

    @Column(precision = 10, scale = 8)
    private BigDecimal latitude;

    @Column(precision = 11, scale = 8)
    private BigDecimal longitude;

    private String locationName;

    private String address;

    @Column(precision = 5, scale = 2)
    private BigDecimal accuracy;

    @Enumerated(EnumType.STRING)
    private LocationSource locationSource;

    private LocalDateTime locationTime;

    @CreationTimestamp
    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    public enum LocationType {
        CHECK_IN,   // 签到
        CHECK_OUT   // 签退
    }

    public enum LocationSource {
        GPS,        // GPS定位
        NETWORK,    // 网络定位
        MANUAL      // 手动输入
    }
}